#include "expr.h"
#include "symbol.h"

ConstantExpr::ConstantExpr(const char* str,const_expr_type t){
    value = new std::string(str);
    type = t;
    constSym = 0;
};

class   IntegerSymbol : public ConstantSymbol{
public:
    IntegerSymbol(std::string *str,int i):ConstantSymbol(str,i){};
    virtual int isInteger(){return 1;};
};

class   StringSymbol : public ConstantSymbol{
public:
    StringSymbol(std::string *str,int i):ConstantSymbol(str,i){};
    virtual int isString(){return 1;}
};

/// the symbols in the constant pool
std::vector<ConstantSymbol*> ConstantPool::syms;
int ConstantPool::index;

ConstantSymbol* ConstantPool::createInteger(std::string *str){
    ConstantSymbol *sym = new IntegerSymbol(str,index++);
    syms.push_back(sym);
    return  sym;
}

ConstantSymbol* ConstantPool::createString(std::string *str){
    ConstantSymbol *sym = new StringSymbol(str,index++);
    syms.push_back(sym);
    return  sym;
}
